package com.ymttest.business.database;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import com.ymt.core.tool.Logger;
import com.ymttest.common.entitie.LimitProductInfo;
import com.ymttest.database.model.YmtCatalogs;
import com.ymttest.database.model.YmtPictures;
import com.ymttest.database.model.YmtProductDescription;
import com.ymttest.database.model.YmtProducts;
import com.ymttest.database.sqlwapper.YmtCatalogsWapper;
import com.ymttest.database.sqlwapper.YmtPicturesWapper;
import com.ymttest.database.sqlwapper.YmtProductDescriptionWapper;
import com.ymttest.database.sqlwapper.YmtProductsWapper;
import com.ymttest.database.sqlwapper.YmtUsersWapper;
import com.ymttest.utils.TestDataManager;

/************************************************************************************
 * 商品相关
 * 
 * @File name : ProductInfo.java
 * @Author : zhouyi
 * @Date : 2015年5月19日
 * @Copyright : 洋码头
 ************************************************************************************/
public class ProductInfo {
	static YmtPicturesWapper ymtpw = new YmtPicturesWapper();
	static YmtUsersWapper yuw = new YmtUsersWapper();
	static YmtCatalogsWapper ycw = new YmtCatalogsWapper();
	static YmtProductDescriptionWapper ypdw = new YmtProductDescriptionWapper();
	static YmtProductsWapper ypw = new YmtProductsWapper();

	/**
	 * 自动用isellerid 商户创建一个商品 调用该方法会向表YmtProducts YmtCatalogs
	 * YmtProductDescription YmtPictures 插入商品数据信息
	 * 
	 * @param isellerid
	 *            商户id
	 * @param limitnum
	 *            商品限购数量 小于0为随机数
	 * @return Map {sproductid=3bd2e4c2-005d-44f0-8f9e-9c3da7626752,
	 *         isellerid=1362789, bCantUseGift=true,
	 *         scatalogid=830446c7-dc3a-48c7-852f-8b24ef1d0b57, Fflight=46,
	 *         bCanGift=false, sProduct=自动化测试Sproduct, irecentsellnum=12,
	 *         loginid=sililankaseller, ilimitnum=1, isellnum=90,
	 *         iCatalogStatus=3, inum=189, fWeight=37,
	 *         sPicUrl=http://p243.img.ymatou
	 *         .com:10243/upload/product/original/69d
	 *         cafefc19440d997c13e0a8d7ed46b_o.jpg, fQuotePrice=87}
	 * 
	 * @throws InterruptedException
	 */
	public static Map<String, Comparable> createProduct(int isellerid, int limitnum) throws InterruptedException {
		Map<String, Comparable> rem = new HashMap<String, Comparable>();
		rem.put("isellerid", isellerid);
		YmtProducts productsinfo = new YmtProducts();
		// sproductid 随机生成
		rem.put("sproductid", TestDataManager.getRandomUUID().toString());
		productsinfo.setSproductid((String) rem.get("sproductid"));
		// 该产品有效时间是今天到明天 时间相关
		Calendar calendar = Calendar.getInstance();
		Date now = calendar.getTime();
		calendar.add(Calendar.DAY_OF_MONTH, 1);
		Date next = calendar.getTime();
		productsinfo.setValidstart(now);
		productsinfo.setDaddtime(now);
		productsinfo.setDlastupdate(now);
		productsinfo.setDlastcatalogtime(now);
		productsinfo.setValidend(next);
		// 1是护航直
		productsinfo.setIsailprotected(1);
		// pic
		rem.put("sPicUrl",
				"http://p243.img.ymatou.com:10243/upload/product/original/69dcafefc19440d997c13e0a8d7ed46b_o.jpg");
		productsinfo.setSpicurl((String) rem.get("sPicUrl"));
		// 这个必须是0
		productsinfo.setIaction(0);
		// 随机是否能用红包
		rem.put("bCanGift", new Random().nextBoolean());
		productsinfo.setBcangift((Boolean) rem.get("bCanGift"));
		rem.put("bCantUseGift", new Random().nextBoolean());
		productsinfo.setBcantusegift((Boolean) rem.get("bCantUseGift"));
		// 目前固定3 用于处理运输类型
		rem.put("iCatalogStatus", 3);
		productsinfo.setIcatalogstatus((Integer) rem.get("iCatalogStatus"));
		// uid
		productsinfo.setIuserid((Integer) rem.get("isellerid"));
		// 产品大类3 目前固定
		int ThirdCategoryId = 1155;
		rem.put("ThirdCategoryId", ThirdCategoryId);
		productsinfo.setIthirdcategoryid(ThirdCategoryId);
		// 产品大类2 目前固定
		int CategoryId = 1154;
		rem.put("CategoryId", CategoryId);
		productsinfo.setIcategoryid(CategoryId);
		// 产品小类 目前固定
		int BrandId = 10698;
		rem.put("BrandId", BrandId);
		productsinfo.setIbrandid(BrandId);
		// 默认true
		productsinfo.setBymtproduct(true);
		rem.put("sProduct", "自动化测试Product");
		productsinfo.setSproduct("自动化测试Product");
		// isellnum irecentsellnum istocknum 是做什么用的？
		rem.put("isellnum", new Random().nextInt(100));
		productsinfo.setIsellnum((Integer) rem.get("isellnum"));
		rem.put("irecentsellnum", new Random().nextInt(100));
		productsinfo.setIrecentsellnum((Integer) rem.get("irecentsellnum"));
		productsinfo.setIstocknum(0);
		int ilimitnum = 0;
		// 如果外面传入的限购数量>=0 保持一致，如果小于0 给个随机数
		if (limitnum >= 0) {
			ilimitnum = limitnum;
		} else {
			ilimitnum = new Random().nextInt(3) + 2;
		}
		rem.put("ilimitnum", ilimitnum);
		productsinfo.setIlimitnum((Integer) rem.get("ilimitnum"));
		// 限购开始时间
		productsinfo.setDlimitnumstarttime(now);
		// 不是闪购
		productsinfo.setBshangouproduct(0);
		// 热卖？
		productsinfo.setIhot(1);
		// iAttention 默认0？
		productsinfo.setIattention(0);
		// iTranslateState 默认0？
		productsinfo.setItranslatestate(0);
		// Itype 默认0？
		productsinfo.setItype(0);
		// bHidden false？
		productsinfo.setBhidden(false);
		// Bforvip false？
		productsinfo.setBforvip(false);
		// Bautorefresh false？
		productsinfo.setBautorefresh(false);
		// Bonsalebyseller false？
		productsinfo.setBonsalebyseller(false);
		// iIsMerchant 0?
		productsinfo.setIismerchant(0);
		// iCatalogType 0 现货
		productsinfo.setIcatalogtype(0);
		// fWeight 重量 Fflight 自定义运费
		DecimalFormat df = new DecimalFormat("0.00");
		rem.put("Fflight", new BigDecimal(df.format((new Random().nextInt(100)))));
		productsinfo.setFflight((BigDecimal) rem.get("Fflight"));
		rem.put("fWeight", new BigDecimal(df.format((new Random().nextInt(100)))));
		productsinfo.setFweight((BigDecimal) rem.get("fWeight"));
		// Checkstatus 0
		productsinfo.setCheckstatus(0);
		ypw.insertProducts(productsinfo);

		YmtCatalogs catalogsinfo = new YmtCatalogs();
		rem.put("scatalogid", TestDataManager.getRandomUUID().toString());
		catalogsinfo.setScatalogid((String) rem.get("scatalogid"));
		catalogsinfo.setIuserid(isellerid);
		catalogsinfo.setSproductid((String) rem.get("sproductid"));
		String loginid = yuw.getLoginId(isellerid);
		rem.put("loginid", loginid);
		catalogsinfo.setSuser((String) rem.get("loginid"));
		// 原价
		rem.put("fQuotePrice", new BigDecimal(df.format((new Random().nextInt(100)))));
		catalogsinfo.setFquoteprice((BigDecimal) rem.get("fQuotePrice"));
		catalogsinfo.setFflight(new BigDecimal(0));
		catalogsinfo.setDaddtime(now);
		catalogsinfo.setIaction(0);
		// 0为现货
		catalogsinfo.setIcatalogtype(0);
		// iAcceptReturn 1
		catalogsinfo.setIacceptreturn(1);
		// iCatalogStatus 3
		catalogsinfo.setIcatalogstatus(3);
		// iExpire 36524
		catalogsinfo.setIexpire(36524);
		// 库存
		rem.put("inum", new Random().nextInt(100) + 100);
		catalogsinfo.setInum((Integer) rem.get("inum"));
		// 限购
		catalogsinfo.setIlimitnum((Integer) rem.get("ilimitnum"));
		// 热卖？
		catalogsinfo.setIhot(1);
		catalogsinfo.setSsku("77");
		catalogsinfo.setIskutype(0);
		ycw.insertYmtCatalogs(catalogsinfo);

		YmtProductDescription description = new YmtProductDescription();
		description.setSproductid((String) rem.get("sproductid"));
		description.setMdescription("description:自动化测试增加商品");
		ypdw.insertYmtProductDescription(description);

		ArrayList<String> pics = new ArrayList<String>();
		// 此处使用3张固定图片
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/9489d306be114d158bb7bb0825b8678c_o.jpg");
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/a5d2c4ef03ae49d48cd6009ee82d495c_o.jpg");
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/69dcafefc19440d997c13e0a8d7ed46b_o.jpg");
		for (String pic : pics) {
			YmtPictures picinfo = new YmtPictures();
			picinfo.setItype(2);
			picinfo.setStitle("Title-自动化新建商品");
			picinfo.setSkey((String) rem.get("sproductid"));
			picinfo.setSurl(pic);
			String[] fns = pic.split("/");
			String fn = fns[fns.length - 1];
			picinfo.setSfilename(fn);
			picinfo.setMdescript("自动化新建商品图片描述：" + fn);
			picinfo.setDaddtime(now);
			picinfo.setIaction(0);
			ymtpw.insertYmtPictures(picinfo);
		}
		return rem;
	}

	/**
	 * 自动用isellerid 商户创建一个商品 调用该方法会向表YmtProducts YmtCatalogs
	 * YmtProductDescription YmtPictures 插入商品数据信息
	 * 
	 * @param isellerid
	 *            商户id
	 * @param limitnum
	 *            商品限购数量 小于0为随机数
	 * @param productName
	 *            商品名称
	 */
	public static Map<String, Comparable> createProduct(int isellerid, int limitnum, String productName)
			throws InterruptedException {
		Map<String, Comparable> rem = new HashMap<String, Comparable>();
		rem.put("isellerid", isellerid);
		YmtProducts productsinfo = new YmtProducts();
		// sproductid 随机生成
		rem.put("sproductid", TestDataManager.getRandomUUID().toString());
		productsinfo.setSproductid((String) rem.get("sproductid"));
		// 该产品有效时间是今天到明天 时间相关
		Calendar calendar = Calendar.getInstance();
		Date now = calendar.getTime();
		calendar.add(Calendar.DAY_OF_MONTH, 1);
		Date next = calendar.getTime();
		productsinfo.setValidstart(now);
		productsinfo.setDaddtime(now);
		productsinfo.setDlastupdate(now);
		productsinfo.setDlastcatalogtime(now);
		productsinfo.setValidend(next);
		// pic
		rem.put("sPicUrl",
				"http://p243.img.ymatou.com:10243/upload/product/original/69dcafefc19440d997c13e0a8d7ed46b_o.jpg");
		productsinfo.setSpicurl((String) rem.get("sPicUrl"));
		// 这个必须是0
		productsinfo.setIaction(0);
		// 随机是否能用红包
		rem.put("bCanGift", new Random().nextBoolean());
		productsinfo.setBcangift((Boolean) rem.get("bCanGift"));
		rem.put("bCantUseGift", new Random().nextBoolean());
		productsinfo.setBcantusegift((Boolean) rem.get("bCantUseGift"));
		// 目前固定3 用于处理运输类型
		rem.put("iCatalogStatus", 3);
		productsinfo.setIcatalogstatus((Integer) rem.get("iCatalogStatus"));
		// uid
		productsinfo.setIuserid((Integer) rem.get("isellerid"));
		// 产品大类3 目前固定
		int ThirdCategoryId = 1155;
		rem.put("ThirdCategoryId", ThirdCategoryId);
		productsinfo.setIthirdcategoryid(ThirdCategoryId);
		// 产品大类2 目前固定
		int CategoryId = 1154;
		rem.put("CategoryId", CategoryId);
		productsinfo.setIcategoryid(CategoryId);
		// 产品小类 目前固定
		int BrandId = 10698;
		rem.put("BrandId", BrandId);
		productsinfo.setIbrandid(BrandId);
		// 默认true
		productsinfo.setBymtproduct(true);
		rem.put("sProduct", productName);
		productsinfo.setSproduct(productName);
		// isellnum irecentsellnum istocknum 是做什么用的？
		rem.put("isellnum", new Random().nextInt(100));
		productsinfo.setIsellnum((Integer) rem.get("isellnum"));
		rem.put("irecentsellnum", new Random().nextInt(100));
		productsinfo.setIrecentsellnum((Integer) rem.get("irecentsellnum"));
		productsinfo.setIstocknum(0);
		productsinfo.setIsailprotected(0);
		int ilimitnum = 0;
		// 如果外面传入的限购数量>=0 保持一致，如果小于0 给个随机数
		if (limitnum >= 0) {
			ilimitnum = limitnum;
		} else {
			ilimitnum = new Random().nextInt(3) + 2;
		}
		rem.put("ilimitnum", ilimitnum);
		productsinfo.setIlimitnum((Integer) rem.get("ilimitnum"));
		// 限购开始时间
		productsinfo.setDlimitnumstarttime(now);
		// 不是闪购
		productsinfo.setBshangouproduct(0);
		// 热卖？
		productsinfo.setIhot(1);
		// iAttention 默认0？
		productsinfo.setIattention(0);
		// iTranslateState 默认0？
		productsinfo.setItranslatestate(0);
		// Itype 默认0？
		productsinfo.setItype(0);
		// bHidden false？
		productsinfo.setBhidden(false);
		// Bforvip false？
		productsinfo.setBforvip(false);
		// Bautorefresh false？
		productsinfo.setBautorefresh(false);
		// Bonsalebyseller false？
		productsinfo.setBonsalebyseller(false);
		// iIsMerchant 0?
		productsinfo.setIismerchant(0);
		// iCatalogType 0 现货
		productsinfo.setIcatalogtype(0);
		// fWeight 重量 Fflight 自定义运费
		DecimalFormat df = new DecimalFormat("0.00");
		rem.put("Fflight", new BigDecimal(df.format((new Random().nextInt(100)))));
		productsinfo.setFflight((BigDecimal) rem.get("Fflight"));
		rem.put("fWeight", new BigDecimal(df.format((new Random().nextInt(100)))));
		productsinfo.setFweight((BigDecimal) rem.get("fWeight"));
		// Checkstatus 0
		productsinfo.setCheckstatus(0);
		ypw.insertProducts(productsinfo);

		YmtCatalogs catalogsinfo = new YmtCatalogs();
		rem.put("scatalogid", TestDataManager.getRandomUUID().toString());
		catalogsinfo.setScatalogid((String) rem.get("scatalogid"));
		catalogsinfo.setIuserid(isellerid);
		catalogsinfo.setSproductid((String) rem.get("sproductid"));
		String loginid = yuw.getLoginId(isellerid);
		rem.put("loginid", loginid);
		catalogsinfo.setSuser((String) rem.get("loginid"));
		// 原价
		rem.put("fQuotePrice", new BigDecimal(df.format((new Random().nextInt(100)))));
		catalogsinfo.setFquoteprice((BigDecimal) rem.get("fQuotePrice"));
		catalogsinfo.setFflight(new BigDecimal(0));
		catalogsinfo.setDaddtime(now);
		catalogsinfo.setIaction(0);
		// 0为现货
		catalogsinfo.setIcatalogtype(0);
		// iAcceptReturn 1
		catalogsinfo.setIacceptreturn(1);
		// iCatalogStatus 3
		catalogsinfo.setIcatalogstatus(3);
		// iExpire 36524
		catalogsinfo.setIexpire(36524);
		// 库存
		rem.put("inum", new Random().nextInt(100) + 100);
		catalogsinfo.setInum((Integer) rem.get("inum"));
		// 限购
		catalogsinfo.setIlimitnum((Integer) rem.get("ilimitnum"));
		// 热卖？
		catalogsinfo.setIhot(1);
		catalogsinfo.setSsku("77");
		catalogsinfo.setIskutype(0);
		ycw.insertYmtCatalogs(catalogsinfo);

		YmtProductDescription description = new YmtProductDescription();
		description.setSproductid((String) rem.get("sproductid"));
		description.setMdescription("description:自动化测试增加商品");
		ypdw.insertYmtProductDescription(description);

		ArrayList<String> pics = new ArrayList<String>();
		// 此处使用3张固定图片
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/9489d306be114d158bb7bb0825b8678c_o.jpg");
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/a5d2c4ef03ae49d48cd6009ee82d495c_o.jpg");
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/69dcafefc19440d997c13e0a8d7ed46b_o.jpg");
		for (String pic : pics) {
			YmtPictures picinfo = new YmtPictures();
			picinfo.setItype(2);
			picinfo.setStitle("Title-自动化新建商品");
			picinfo.setSkey((String) rem.get("sproductid"));
			picinfo.setSurl(pic);
			String[] fns = pic.split("/");
			String fn = fns[fns.length - 1];
			picinfo.setSfilename(fn);
			picinfo.setMdescript("自动化新建商品图片描述：" + fn);
			picinfo.setDaddtime(now);
			picinfo.setIaction(0);
			ymtpw.insertYmtPictures(picinfo);
		}
		return rem;
	}

	/**
	 * 创建产品（订单金额随机）
	 * 
	 * @param Info
	 * @return
	 */
	public static Map<String, Comparable> createLimitProduct(LimitProductInfo Info) {
		Map<String, Comparable> rem = new HashMap<String, Comparable>();
		DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
		BigDecimal price1 = new BigDecimal(df.format(new Random().nextFloat()));
		Integer SellerId = Info.getSellerId();
		YmtProducts productsinfo = new YmtProducts();
		// sproductid 随机生成
		rem.put("ProductId", TestDataManager.getRandomUUID().toString());
		productsinfo.setSproductid((String) rem.get("ProductId"));
		// 该产品有效时间是今天到明天 时间相关
		Calendar calendar = Calendar.getInstance();
		Date now = calendar.getTime();
		calendar.add(Calendar.DAY_OF_MONTH, 1);
		Date next = calendar.getTime();
		productsinfo.setValidstart(now);
		productsinfo.setDaddtime(now);
		productsinfo.setDlastupdate(now);
		productsinfo.setDlastcatalogtime(now);
		productsinfo.setValidend(next);
		// pic
		rem.put("sPicUrl",
				"http://p243.img.ymatou.com:10243/upload/product/original/69dcafefc19440d997c13e0a8d7ed46b_o.jpg");
		productsinfo.setSpicurl((String) rem.get("sPicUrl"));
		// 这个必须是0
		productsinfo.setIaction(0);
		// 随机是否能用红包
		boolean CanGift = Info.isCanGift();
		// rem.put("bCanGift", new Random().nextBoolean());
		productsinfo.setBcangift(CanGift);
		boolean CantUseGift = Info.isCantUseGift();
		// rem.put("bCantUseGift", new Random().nextBoolean());
		productsinfo.setBcantusegift(CantUseGift);
		// 目前固定3用于处理运输类型 0-未知,1-国内,2-美国直邮,3-护航,4-保税发货,5-贝海保税发货
		rem.put("iCatalogStatus", 3);
		productsinfo.setIcatalogstatus((Integer) rem.get("iCatalogStatus"));
		// uid
		productsinfo.setIuserid(SellerId);
		// 产品大类3 目前固定
		int ThirdCategoryId = 1155;
		rem.put("ThirdCategoryId", ThirdCategoryId);
		productsinfo.setIthirdcategoryid(ThirdCategoryId);
		// 产品大类2 目前固定
		int CategoryId = 1154;
		rem.put("CategoryId", CategoryId);
		productsinfo.setIcategoryid(CategoryId);
		// 产品小类 目前固定
		int BrandId = 10698;
		rem.put("BrandId", BrandId);
		productsinfo.setIbrandid(BrandId);
		// 默认true
		productsinfo.setBymtproduct(true);
		rem.put("sProduct", "自动化测试Product");
		productsinfo.setSproduct("自动化测试Product");
		// isellnum irecentsellnum istocknum 是做什么用的？
		rem.put("isellnum", new Random().nextInt(100));
		productsinfo.setIsellnum((Integer) rem.get("isellnum"));
		rem.put("irecentsellnum", new Random().nextInt(100));
		productsinfo.setIrecentsellnum((Integer) rem.get("irecentsellnum"));
		productsinfo.setIstocknum(0);
		productsinfo.setIsailprotected(0);
		productsinfo.setIlimitnum(Info.getLimitNum());
		// 限购开始时间
		productsinfo.setDlimitnumstarttime(now);
		// 不是闪购
		productsinfo.setBshangouproduct(Info.getShanGouProduct());
		// 热卖？
		productsinfo.setIhot(1);
		// iAttention 默认0？
		productsinfo.setIattention(0);
		// iTranslateState 默认0？
		productsinfo.setItranslatestate(0);
		// Itype 默认0？
		productsinfo.setItype(0);
		// bHidden false？
		productsinfo.setBhidden(false);
		// Bforvip false？
		productsinfo.setBforvip(false);
		// Bautorefresh false？
		productsinfo.setBautorefresh(false);
		// Bonsalebyseller false？
		productsinfo.setBonsalebyseller(false);
		// iIsMerchant 0?
		productsinfo.setIismerchant(0);
		// iCatalogType 0 现货
		productsinfo.setIcatalogtype(0);
		// fWeight 重量 Fflight 自定义运费
		rem.put("Fflight", new BigDecimal(df.format((new Random().nextInt(100)))));
		productsinfo.setFflight((BigDecimal) rem.get("Fflight"));
		rem.put("fWeight", new BigDecimal(df.format((new Random().nextInt(100)))));
		productsinfo.setFweight((BigDecimal) rem.get("fWeight"));
		// Checkstatus 0
		productsinfo.setCheckstatus(0);
		ypw.insertProducts(productsinfo);
		YmtCatalogs catalogsinfo = new YmtCatalogs();
		rem.put("scatalogid", TestDataManager.getRandomUUID().toString());
		catalogsinfo.setScatalogid((String) rem.get("scatalogid"));
		catalogsinfo.setIuserid(SellerId);
		catalogsinfo.setSproductid((String) rem.get("ProductId"));
		String loginid = yuw.getLoginId(SellerId);
		catalogsinfo.setSuser(loginid);
		// 原价
		BigDecimal price2 = new BigDecimal(df.format((new Random().nextInt(100))));
		rem.put("fQuotePrice", price1.add(price2));
		catalogsinfo.setFquoteprice((BigDecimal) rem.get("fQuotePrice"));
		catalogsinfo.setFflight(new BigDecimal(0));
		catalogsinfo.setDaddtime(now);
		catalogsinfo.setIaction(0);
		// 0为现货
		catalogsinfo.setIcatalogtype(0);
		// iAcceptReturn 1
		catalogsinfo.setIacceptreturn(1);
		// iCatalogStatus 3
		catalogsinfo.setIcatalogstatus(3);
		// iExpire 36524
		catalogsinfo.setIexpire(36524);
		// 库存
		Integer StockNum = Info.getStockNum();
		catalogsinfo.setInum(StockNum);
		// 限购
		catalogsinfo.setIlimitnum((Info.getLimitNum()));
		// 热卖？
		catalogsinfo.setIhot(1);
		catalogsinfo.setSsku("77");
		catalogsinfo.setIskutype(0);
		ycw.insertYmtCatalogs(catalogsinfo);
		YmtProductDescription description = new YmtProductDescription();
		description.setSproductid((String) rem.get("ProductId"));
		description.setMdescription("description:自动化测试增加商品");
		ypdw.insertYmtProductDescription(description);
		ArrayList<String> pics = new ArrayList<String>();
		// 此处使用3张固定图片
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/9489d306be114d158bb7bb0825b8678c_o.jpg");
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/a5d2c4ef03ae49d48cd6009ee82d495c_o.jpg");
		pics.add("http://p243.img.ymatou.com:10243/upload/product/original/69dcafefc19440d997c13e0a8d7ed46b_o.jpg");
		for (String pic : pics) {
			YmtPictures picinfo = new YmtPictures();
			picinfo.setItype(2);
			picinfo.setStitle("Title-自动化新建商品");
			picinfo.setSkey((String) rem.get("sproductid"));
			picinfo.setSurl(pic);
			String[] fns = pic.split("/");
			String fn = fns[fns.length - 1];
			picinfo.setSfilename(fn);
			picinfo.setMdescript("自动化新建商品图片描述：" + fn);
			picinfo.setDaddtime(now);
			picinfo.setIaction(0);
			ymtpw.insertYmtPictures(picinfo);
		}
		return rem;
	}

	public static void main(String args[]) {
		// 1362789 sililankaseller sililankaseller@163.com 123456
		// new ProductInfo().createProduct(1362789, -1);
		// LimitProductInfo info = new LimitProductInfo();
		// info.setSellerId(288484);
		// info.setCanGift(true);
		// info.setCantUseGift(true);
		// info.setExpire(2);
		// info.setLimitNum(3);
		// info.setStockNum(21);
		// info.setShanGouProduct(1);
		// new ProductInfo().createLimitProduct(info);
		try {
			Logger.debug("new product:" + ProductInfo.createProduct(288484, 10, "xxxxxxxx"));
		} catch (InterruptedException e) {

			e.printStackTrace();
		}
	}
}
